package com.gollum.system.domain.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.gollum.jpa.domain.HertherBaseEnity;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

/**
 * 菜单资源表
 *
 * @author Herther
 * @version 1.0.0
 * @createTime 2022年08月25日 21:07:00
 */
@Getter
@Setter
@AllArgsConstructor
@Accessors(chain=true)
@NoArgsConstructor
@Entity
@Table(name = "sys_menu")
@EntityListeners(AuditingEntityListener.class)
public class SysMenu extends HertherBaseEnity {

    private static final long serialVersionUID = 1L;


    /** 菜单名称 国际化词条 */
    @Column(name = "name")
    private String name;

    ///** 父菜单名称 **/
    //private String parentName;

    /** 父菜单ID */
    @Column(name = "parent_id",length = 50)
    private Long parentId;

    /** 自己关联自己 **/
    @OneToMany(mappedBy = "sysMenu")
    @JsonIgnore
    private List<SysMenu> children;

    @ManyToOne
    @JoinColumn(name = "parent_id", insertable = false, updatable = false)
    private SysMenu sysMenu;

    /** 菜单编码 **/
    @Column(name = "code",length = 50)
    private String code;

    /** 显示顺序 */
    @Column(name = "sort",length = 50)
    private Integer sort;

    /** 请求地址 */
    @Column(name = "path")
    private String path;

    /** 组件路径 */
    @Column(name = "component")
    private String component;

    /** 别名  **/
    @Column(name = "alias",length = 100)
    private String alias;

    /** 类型（M目录 C菜单 F按钮） */
    @Column(name = "type",length = 10)
    private String type;

    /** 显示状态（0显示 1隐藏） */
    @Column(name = "visible",length = 10)
    private String visible;

    /** 菜单状态（0正常 1停用) */
    @Column(name = "status",length = 10)
    private String status;

    /** 权限字符串 */
    @Column(name = "perms",length = 100)
    private String perms;

    /** 菜单图标 */
    @Column(name = "icon",length = 100)
    private String icon;

}
